#ifndef CRECTPICKCOLOR_H
#define CRECTPICKCOLOR_H

#include <QWidget>
#include <QPainter>
class CRectPickColor : public QWidget
{
    Q_OBJECT
public:
    explicit CRectPickColor(QWidget *parent = nullptr);

    void setPickRowCol(int nRowCnt, int nColCnt);   //设置取色器行列
    void setCellRadius(int nCellRadius);
    void setCellMargins(int nAllMargin);
    void setCellMargins(QMargins margins);
signals:
    void sigSelected(QColor color);
public slots:
    void setColor(QColor color);
protected:
    void mousePressEvent(QMouseEvent *event) override;
    void paintEvent(QPaintEvent *event) override;

    void drawCell(QPainter &painter, QRect &rect, qreal dCellLightness); //nCellLightness 0.0~1.0
private:
    QPoint m_ptClicked;
    QColor m_colorSelected = Qt::white;
    int m_nCellRadius = 5; //方格圆角

    int m_nMaxCol = 10;
    int m_nMaxRow = 10;

    QMargins m_marginCell = QMargins(2,2,2,2);
};

#endif // CRECTPICKCOLOR_H
